using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SaveManager : Singleton<SaveManager>
{
    public Dictionary<int, Level> levelData = new Dictionary<int, Level>();

    protected override void Awake()
    {
        base.Awake();
        
        
        
    }

    private void LoadLevelData()
    {
        
    }

    public void RemoveLevelData(int levelIndex)
    {
        levelData.Remove(levelIndex);
        Debug.LogFormat("Remove Level Data:{0}", levelIndex);
    }
    

    public void SaveLevelData(int levelIndex,Level level)
    {
        if (levelData.ContainsKey(levelIndex))
        {
            levelData[levelIndex] = level;
        }
        else
        {
            levelData.Add(levelIndex, level);
        }
        Debug.LogFormat("Save Level Data:{0},{1}. cellNums : {2}", levelIndex, level,level.cells.Count);
    }

    public bool CheckLevelExist(int levelIndex)
    {
        return levelData.ContainsKey(levelIndex);
    }

    public Level LoadLevel(int levelIndex)
    {
        if (levelData.ContainsKey(levelIndex))
        {
            if (levelData[levelIndex] != null)
            {
                return levelData[levelIndex];
            }
        }
        return null;
    }
}
